/*
 * Copyright (C) 2013  Richard Schilling. All rights reserved.
 * contact: coderroadie@gmail.com
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package android.net.quic.enumerations;

/**
 * The public flags are specified in one byte.
 * 
 * @author Richard Schilling
 */
public enum QuicPacketPublicFlags {
    PACKET_PUBLIC_FLAGS_NONE(0),

    // Bit 0: Does the packet header contains version info?
    PACKET_PUBLIC_FLAGS_VERSION(1 << 0),

    // Bit 1: Is this packet a public reset packet?
    PACKET_PUBLIC_FLAGS_RST(1 << 1),

    // Bits 2 and 3 specify the length of the GUID as follows:
    // ----00--: 0 bytes
    // ----01--: 1 byte
    // ----10--: 4 bytes
    // ----11--: 8 bytes
    PACKET_PUBLIC_FLAGS_0BYTE_GUID(0),
    PACKET_PUBLIC_FLAGS_1BYTE_GUID(1 << 2),
    PACKET_PUBLIC_FLAGS_4BYTE_GUID(1 << 3),
    PACKET_PUBLIC_FLAGS_8BYTE_GUID(1 << 3 | 1 << 2),

    // Bits 4 and 5 describe the packet sequence number length as follows:
    // --00----: 1 byte
    // --01----: 2 bytes
    // --10----: 4 bytes
    // --11----: 6 bytes
    PACKET_PUBLIC_FLAGS_1BYTE_SEQUENCE(0),
    PACKET_PUBLIC_FLAGS_2BYTE_SEQUENCE(1 << 4),
    PACKET_PUBLIC_FLAGS_4BYTE_SEQUENCE(1 << 5),
    PACKET_PUBLIC_FLAGS_6BYTE_SEQUENCE(1 << 5 | 1 << 4),

    // All bits set (bits 6 and 7 are not currently used): 00111111
    PACKET_PUBLIC_FLAGS_MAX((1 << 6) - 1);

    /**
     * The unsigned byte value of the flag.
     */
    public final int flagValue;

    private QuicPacketPublicFlags(int value) {
        flagValue = value;
    }
}
